<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<div class="panel">
    <div id="energyBill-heading" class="panel-heading bg-gray-light">
        <h3 class="panel-title">基本信息-能源账单<span id="title-duty-name-energyBill" class="text-muted"> | </span></h3>
    </div>

    <div class="panel-body">
        <form th:id="'form_energyBill_input'+${energyBill?.id}" class="form-horizontal" autocomplete="off">
            <input type="hidden" name="keyId" th:value="${energyBill?.id}">
            <input type="hidden" name="flowDutyId">
            <input type="hidden" name="flowDutyName">

            <div class="form-group">
                <label class="col-md-2 control-label">名称<i class="fa fa-asterisk txt-color-red"></i></label>
                <div class="col-md-8">
                    <input type="text" name="name" id="name" th:value="${energyBill?.name}" class="form-control" placeholder="名称">
                </div>
            </div>

        
            <div class="form-group">
                <label class="col-md-2 control-label">账单类型<i class="fa fa-asterisk txt-color-red"></i></label>
                <div class="col-md-8">
                    <input type="text" name="energyTypeDictId" id="energyTypeDictId" th:value="${energyBill?.energyTypeDict}" class="form-control" placeholder="energyTypeDict">
                </div>
            </div>
        
            <div class="form-group">
                <label class="col-md-2 control-label">账单月份<i class="fa fa-asterisk txt-color-red"></i></label>
                <div class="col-md-8">
                    <input type="text" name="billDate" id="billDate" th:value="${#dates.format(energyBill?.billDate, 'yyyy-MM-dd')}" class="form-control" placeholder="billDate">
                    </div>
            </div>
        
            <div class="form-group">
                <label class="col-md-2 control-label">单价<i class="fa fa-asterisk txt-color-red"></i></label>
                <div class="col-md-8">
                    <input type="text" name="price" id="price" th:value="${energyBill?.price}" class="form-control" placeholder="price">
                </div>
            </div>
        
            <div class="form-group">
                <label class="col-md-2 control-label">使用量<i class="fa fa-asterisk txt-color-red"></i></label>
                <div class="col-md-8">
                    <input type="text" name="useCount" id="useCount" th:value="${energyBill?.useCount}" class="form-control" placeholder="useCount">
                </div>
            </div>
        
            <div class="form-group">
                <label class="col-md-2 control-label">总金额<i class="fa fa-asterisk txt-color-red"></i></label>
                <div class="col-md-8">
                    <input type="text" name="totalAmount" id="totalAmount" th:value="${energyBill?.totalAmount}" class="form-control" placeholder="totalAmount">
                </div>
            </div>
        
            <div class="form-group">
                <label class="col-md-2 control-label">条形码<i class="fa fa-asterisk txt-color-red"></i></label>
                <div class="col-md-8">
                    <input type="text" name="barcode" id="barcode" th:value="${energyBill?.barcode}" class="form-control" placeholder="barcode">
                </div>
            </div>
        
            <div class="form-group">
                <label class="col-md-2 control-label">备注<i class="fa fa-asterisk txt-color-red"></i></label>
                <div class="col-md-8">
                    <input type="text" name="remark" id="remark" th:value="${energyBill?.remark}" class="form-control" placeholder="remark">
                </div>
            </div>
        
        </form>
    </div>
</div>

<script th:inline="javascript">
    var keyId_energyBill = [[${energyBill?.id}]];
    var flowData_energyBill = {
        keyId : keyId_energyBill ? keyId_energyBill : "create",
        formId : "form_energyBill_input"+[[${energyBill?.id}]],
        path : "com.hanqian.kepler.core.entity.primary.education.EnergyBill",
        titleId : "title-duty-name-energyBill"
    };
    var $form = $("#"+flowData_energyBill.formId);

    $(function(){
        __laydate_date(flowData_energyBill.formId + " #billDate");
        __flow_duty_handle(flowData_energyBill);
        __flow_button_input_handle(flowData_energyBill, fn_energyBill_save, fn_energyBill_commit);
        fn_energyBill_input_validate();

    });

    //表单验证
    function fn_energyBill_input_validate(){
        __init_validate(flowData_energyBill.formId, {
            rules : {
                name : {required : true},
                energyTypeDictId : {required : true},
                billDate : {required : true},
                price : {required : true, number : true},
                useCount : {required : true, number : true},
                totalAmount : {required : true, number : true},
                barcode : {required : true},
                remark : {required : true}
            }
        });
    }

    //保存方法
    function fn_energyBill_save(){
        __confirm_dialog("", "确认保存吗？", function(){
            __form_save(flowData_energyBill.formId, "/energyBill/save", function(data){
                if(data && data.state === 1){
                    __flow_close_layx(flowData_energyBill);
                }
            })
        })
    }

    //提交方法
    function fn_energyBill_commit(){
        if(!$("#" + flowData_energyBill.formId).valid()){
            return false;
        }
        __confirm_dialog("", "确认提交吗？", function(){
            __form_save(flowData_energyBill.formId, "/energyBill/commit", function(data){
                if(data && data.state === 1){
                    __flow_close_layx(flowData_energyBill);
                }
            })
        })
    }

</script>

</html>